Testing and quality control is a crucial part of software development, and should be done throughout all stages of the software development lifecycle. A software developer should test all the code he or she programmed for proper and exception-free operation, as well as ensuring that the code provided the expected results.
Defects, also known as bugs, may be introduced to a piece of software at any development phase, including for example during initial programming, at a later time when existing code is changed for adding new functionalities or for fixing other bugs, or further later when changing other pieces of code which influence or are influenced by the current code. Thus, in many cases bugs are introduced into a piece of code which was already tested and approved, but changes in that piece of code or in other parts caused the bug. Of course, the later a bug is discovered, the harder it is to localize it so it can be fixed, and the more expensive and resource consuming it is to fix it. Currently, it is hard to identify a new bug in code which has already been known to work properly.
Unit testing is a concept according to which individual units of source code are tested to determine if they are fit for use. A unit is a part of an application that can be tested independently of other parts. For example, in procedural programming a unit may be an individual function or procedure, while in object-oriented programming a unit may relate to a method or to a class having one or more methods.
The benefits of unit testing, which relate to bug isolation, version management and others, are recognized industry-wide, but many software developers do not perform proper unit testing, because of the added burden and time constraints. Instead, some employ very partial testing during development and rely on tests performed on integration stages, in which additional units are involved. In other cases, developers sometimes perform manual unit testing where they create a temporary program to test their new code and then throw the temporary program away, thus delaying the problem to the next development phase. Automated unit testing, however, is currently hard to implement and its implementation and usage requires a lot of discipline on the user's side.
A major disadvantage of this course of action is that even if a unit has been thoroughly and successfully tested, regression testing is still missing; it is not guaranteed, and indeed is rare, that the tests will be run again or that future versions will remain bug-free. In many cases a developer modifying code in one part of the product introduces bugs into other parts which already work, and these bugs can go unnoticed because the working unit will not be re-tested. This leads to many bugs being discovered at later quality assurance stages at which stage it may hold back other programmers, or even at customer sites, which incurs much higher costs, delayed deadlines and wasted resources.
For example, the cost of fixing a bug during coding is estimated in $25, during unit testing $100, in function testing it is estimated in $250, on system testing it is estimated in $1000, and after releasing the software it increases to as high as $16,000.
There is thus a need for a unit testing method and apparatus for enabling early bug identification during software development.